package com.xinbochuang.machine.admin.controller;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.xinbochuang.machine.admin.dto.ContrastEquCabinetDto;
import com.xinbochuang.machine.admin.service.macRoom.IContrastEquCabinetService;
import com.xinbochuang.machine.common.controller.BaseController;
import com.xinbochuang.machine.framework.web.domain.AjaxResult;

/**
 * @author 杜文博
 * @date 2020-09-21
 */
@RestController
@RequestMapping("/contrast-equ-cabinet")
public class ContrastEquCabinetController extends BaseController {

    @Autowired
    IContrastEquCabinetService iContrastEquCabinetService;

    /**
     * 获取计划核查机柜列表
     */
    //@PreAuthorize("@ss.hasPermi('system:plan:list')")
    @GetMapping("/list")
    public AjaxResult list(ContrastEquCabinetDto contrastEquCabinetDto) {
        List<ContrastEquCabinetDto> result = iContrastEquCabinetService.selectContrasCabinetList(contrastEquCabinetDto);
        Integer totalCount = iContrastEquCabinetService.selectContrasCabinetCount(contrastEquCabinetDto);
        return AjaxResult.data(result, totalCount);
    }

    @GetMapping("/updatEquCabinet")
    public AjaxResult updatEquCabinet(@RequestParam("checkKey") Integer checkKey,
                                      @RequestParam("contrasCabinetIds") String contrasCabinetIds,
                                      @RequestParam("planId") String planId
    ) {
        Integer endResult = iContrastEquCabinetService.updatEquCabinet(checkKey, contrasCabinetIds,planId);
        if (endResult == 1) {
            return toAjax(true);
        } else {
            return toAjax(false);
        }
    }
}

